/**
 * Created by 121 on 2016/4/08.
 */
require.config(require_config);

define([
    'jquery',
    'common',
    'ready',
    'template',
    'collection',
    'model',
    'dialog',
    'calendar',
    'highCharts'
], function ($, common, ready, template, Collection, Model, dialog, calendar, highCharts) {
    var index = function () {
        this.init();
    };
    index.prototype = {
        init: function () {
            this.event();
        },
        event: function () {
            var _this = this;
            $.ajax({
                url: _global.url.api + 'data/detail',
                type: 'get',
                success: function (res) {
                    var data = res;
                    //console.log(data);
                    $('#generalize-detail').highcharts({
                        chart: {
                            zoomType: 'xy'
                        },
                        title: {
                            text: ''
                        },
                        xAxis: {
                            categories: data.categories,
                            labels: {
                                rotation: -45,
                                align: 'right',
                                style: {
                                    fontSize: '10px'
                                }
                            }
                        },
                        yAxis: {
                            title: {
                                text: '次数'
                            }
                        },
                        tooltip: {
                            valueSuffix: ''
                        },
                        legend: {
                            layout: 'vertical',
                            align: 'right',
                            verticalAlign: 'middle',
                            backgroundColor: '#FFFFFF'
                        },
                        series: [{
                            name: '曝光次数',
                            data: data.show_hourly,
                            type: 'spline',
                            tooltip: {
                                valueSuffix: '次'
                            }
                        }, {
                            name: '点击次数',
                            type: 'spline',
                            data: data.click_hourly,
                            tooltip: {
                                valueSuffix: '次'
                            }
                        }, {
                            name: '成交次数',
                            type: 'spline',
                            data: data.click_hourly,
                            tooltip: {
                                valueSuffix: '次'
                            }
                        }]
                    });
                }
            });
        }
    };
    new index();
});